package com.zye.controller;

import com.alibaba.fastjson2.JSON;
import com.zye.entity.Student;
import com.zye.service.StudentService;
import com.zye.service.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/findAll")
public class findAllStudent extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json;charset=utf-8");
        StudentService st=new StudentServiceImpl();
        List<Student> students = st.findAllStudents();
        String str = JSON.toJSONString(students);
        resp.getWriter().write(str);
    }
}
